<template>
	<view class="home-wrap u-m-b-20">
		<wanl-navbar :isBack="true" :background="{background: '#fff',}" :showGongNeng="true">
			<text
				slot="content"
				style="color: #000; width: 100%;padding-left: 20rpx;"
			>
				资讯
			</text>
		</wanl-navbar>
		<view  class="content-box u-p-20 u-m-l-20 u-m-r-20">
			<view class="zixun-item u-flex u-flex-col u-p-20 u-m-t-20" v-for="(item,index) in artList" @click.stop="jump(`/pages/apps/jinyuanbao/shangjia/zixunDetail?zixunId=${item.id}`)">
				<view class="zixunimg u-p-t-10">
					<image :src="$wanlshop.oss(item.img, 88, 88)"></image>
				</view>
				<view style="display: flex;
								justify-content: space-between;
                                align-items: flex-start;
                                flex-direction: column;
                                width: 75%;
                                height: 160rpx;">
					<view class="zixuntitle text-lines-mp u-p-t-10">{{ item.title }}</view>
					<view class="zixuntime u-p-t-10 u-p-b-10">
						<u-icon name="clock" :color="'#999'" size="14" style="margin-right: 4rpx"></u-icon>
						<text>{{item.createtime}}</text>
					</view>
				</view>
			
			</view>
		</view>
		<view class="x-c" style="width: 100%;">
			<!-- 空 -->
			<view v-if="artList.length == 0">
				<wanl-empty src="ticket_default3x" text="暂无资讯内容"/>
			</view>
			<view class="edgeInsetBottom"></view>
			<uni-load-more :status="loadStatus" :content-text="contentText" />
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			artList:[],
			isEmpty: true,
			loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
			currentPage: 1,
			lastPage: 1,
			contentText: {
				contentdown: ' ',
					contentrefresh: '加载中',
					contentnomore: ''
			},
		};
	},
	created() {
		console.log("===artList",this.artList)
		this.initdata();
		// 触底监听
		uni.$on('uOnReachBottom', data => {
			if (this.currentPage < this.lastPage) {
				this.currentPage += 1;
				this.initdata();
			}
		});
	},
	onLoad(options){
		this.shop_id = options.shop_id
	},
	methods:{
		// 路由跳转
		jump(path, parmas) {
			this.$wanlshop.to(path)
		},
		async initdata(){
			let that = this;
			await uni.request({
				url: '/wanlshop/shop/getShopNewsList',
				method: 'POST',
				data: {
					page: this.current_page,
					shop_id:this.shop_id,
					limit:10
				},
				success: res => {
					that.artList = [...that.artList, ...res.data.data];
					that.isEmpty = !that.artList.length;
					that.lastPage = res.data.last_page;
					that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
				},
			});
		},
	}
}
</script>

<style lang="scss" scoped>
page{
	background: #f8f8f8;
}
.zixun-item{
	border-radius: 20rpx;
	background: #fff;
	margin: 30rpx 30rpx 0;
	padding: 20rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	.zixuntitle{
		width: 100%;
		color: #333;
		font-size: 34rpx;
	}
	.zixunimg{
		width: 160rpx;
		height: 160rpx;
		margin-right: 26rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.zixuntime{
		margin-top: 20rpx;
		width: 100%;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		color: #cccccc;
		font-size: 28rpx;
	}
}
</style>
